function t(t) {
    for (var e = -1, a = 0; a < d.length; a++) if (d[a].special_id == t) {
        e = a;
        break;
    }
    return e;
}

function e(t) {
    s.sendrequest("posterapi/getspecial", "POST", {
        token: t,
        spage: o,
        sptype: 1
    }, function(t) {
        1 == t.status && (a.setData({
            speciallist: a.data.speciallist.concat(t.data)
        }), d = d.concat(t.data));
    });
}

var a, i, s = require("../../utils/util.js"), n = 1, r = "", o = 1, u = getApp().globalData.url.imgurl, d = new Array();

Page({
    data: {
        labelList: "",
        imgurl: u,
        posterlist: new Array(),
        emotilist: new Array(),
        curid: 0,
        speciallist: d
    },
    onLoad: function(t) {
        o = 1, a = this;
        var n = wx.getSystemInfoSync();
        this.setData({
            platform: n.platform
        }), s.getToken(function(t) {
            i = t;
        }), s.sendrequest("posterapi/getlabel", "POST", {
            token: i
        }, function(t) {
            1 == t.status && a.setData({
                labelList: t.data
            });
        }), s.sendrequest("posterapi/getclassify", "POST", {
            token: i
        }, function(t) {
            1 == t.status && a.setData({
                classifyList: t.data
            });
        }), s.sendrequest("posterapi/getbanner", "POST", {
            token: i
        }, function(t) {
            1 == t.status && a.setData({
                bannerlist: t.data
            });
        }), e(i);
    },
    cingput: function(t) {
        r = t.detail.value;
    },
    clabel: function(t) {
        a.setData({
            curid: 0
        }), wx.navigateTo({
            url: "/pages/posterlist/posterlist?cateid=" + a.data.curid + "&keyword=" + r + "&label_id=" + t.detail.target.dataset.id
        }), s.getToken(function(e) {
            s.sendrequest("posterapi/setfrom", "POST", {
                token: e,
                formid: t.detail.formId
            }, function(t) {});
        });
    },
    onReachBottom: function() {
        o += 1, e(i);
    },
    onShareAppMessage: function(t) {
        return {
            title: "小婷海报",
            path: "pages/index/index",
            success: function(t) {},
            fail: function(t) {}
        };
    },
    onadapter: function(t) {
        if (t.currentTarget.dataset.url) if (t.currentTarget.dataset.url.indexOf("?is_bottom=1") > 0) {
            var e = t.currentTarget.dataset.url.split("?is_bottom=1");
            wx.switchTab({
                url: e[0]
            });
        } else wx.navigateTo({
            url: t.currentTarget.dataset.url
        });
    },
    submit: function(t) {
        wx.navigateTo({
            url: "/pages/posterlist/posterlist?cateid=" + a.data.curid + "&keyword=" + r
        });
    },
    redirtbyid: function(t) {
        wx.navigateTo({
            url: "/pages/poster/poster?micro_id=" + t.detail.target.dataset.id
        }), s.getToken(function(e) {
            s.sendrequest("posterapi/setfrom", "POST", {
                token: e,
                formid: t.detail.formId
            }, function(t) {});
        });
    },
    posterload: function(e) {
        if (e.currentTarget.dataset.id > 0) {
            var n = t(e.currentTarget.dataset.id);
            d[n].page = parseInt(d[n].page) + 1, s.sendrequest("posterapi/speciallist", "POST", {
                token: i,
                page: d[n].page,
                id: e.currentTarget.dataset.id
            }, function(e) {
                if (1 == e.status) {
                    var i = t(e.data.id);
                    d[i].ilist = d[i].ilist.concat(e.data.list), a.setData({
                        speciallist: d
                    });
                }
            });
        }
    },
    emotiload: function() {
        n += 1, getemotilist(i);
    },
    changeCate: function(t) {
        a.setData({
            curid: t.detail.target.dataset.id
        }), wx.navigateTo({
            url: "/pages/posterlist/posterlist?cateid=" + a.data.curid
        }), s.getToken(function(e) {
            s.sendrequest("posterapi/setfrom", "POST", {
                token: e,
                formid: t.detail.formId
            }, function(t) {});
        });
    }
});